﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CaiGuanJJZ.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS.ShouFeiGL.CaiGuanJJZ" Theme="Default" %>

 <%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../../../../JS/AddEditCancel.js"></script>
    <script src="../../../../JS/jquery.js"></script>
    <script type="text/javascript">
      
        function display(op, id) {
            hdCollection.Set("ID", id);
            if (op == "add") {
                btnAdd.SetVisible(false);
                lblOperateTip.SetText("添加");
                txtYongHuH.SetEnabled(true);
                txtYongHuH.SetText("");
                txtYongHuM.SetText("");
                cmbTeShuLX.SetText("");
                txtShuiLiang.SetText("");
               
                listCover(true, "divList");
                $("#GridViewContentTable").show();
                txtYongHuH.Focus();
            }
            else if (op == "edit") {
                btnAdd.SetVisible(false);
                lblOperateTip.SetText("修改");
                txtYongHuH.SetEnabled(false);
                listCover(true, "divList");
                $("#GridViewContentTable").show();
                ASPxCallback1.PerformCallback("info");
                txtShuiLiang.Focus();
            }
            else {
                $("#GridViewContentTable").hide();
                btnAdd.SetVisible(true);
                listCover(false, "divList");
            }
        }

        function del(id) {
            hdCollection.Set("ID", id);
            if (confirm("确认删除吗？")) {
                ASPxCallback1.PerformCallback("del");
            }
            else {
                hdCollection.Set("ID", -1);
            }
        }

        function save() {
            if (cmbTeShuLX.GetText() == "") {
                alert("特殊类型不能为空！");
                cmbTeShuLX.Focus();
                return;
            }
            if (txtShuiLiang.GetText() == "") {
                alert("水量不能为空！");
                txtShuiLiang.Focus();
                return;
            }
            
            ASPxCallback1.PerformCallback("save");
        }

        function Search() {
            if (txtYongHuH.GetText() == "") {
                alert("用户号不能为空！");
                txtYongHuH.Focus();
                return;
            }
            else {
                ASPxCallback1.PerformCallback("yz");
            }
        }

        function GetNextY() {
            var y =txtShuiLiangN.GetText();
            txtShuiLiangN.SetText(parseInt(y) + 1);
            ASPxCallback1.PerformCallback("nextY");
        }

        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            if (type == "info") {
                txtYongHuH.SetText(arr[2]);
                txtYongHuM.SetText(arr[3]);
                cmbTeShuLX.SetText(arr[4]);
                txtShuiLiang.SetText(arr[5]);
            }
            else if (type == "del") {
                alert(arr[2]);
                gvList.PerformCallback();
            }
            else if (type == "save") {
                alert(arr[2]);
                display("init", -1);
                gvList.PerformCallback();
            }
            else if (type == "yz") {
                if (arr[2] == "0") {
                    alert("不存在此用户，请重新输入用户号！");
                    txtYongHuH.Focus();
                }
                else {
                    txtYongHuM.SetText(arr[2]);
                    //OnKeyNext(cmbTeShuLX);
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            采灌井结账
        </div>
        <div style="display: none;">
            <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
            <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
        </div>
        <asp:UpdatePanel runat="server" ID="updatePanel">
            <ContentTemplate>
                <div>
                    <table>
                        <tr>
                            <td align="right">水量年：</td>
                            <td>
                                <dx:ASPxTextBox runat="server" ID="txtShuiLiangN" ClientEnabled="false" ClientInstanceName="txtShuiLiangN">
                                    <ClientSideEvents  KeyUp="function(s,e){inputFloat(s);}"/>
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                    </table>
                </div>
                <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="0" Width="100%">
                    <TabPages>
                        <dx:TabPage Text="特列">
                            <ContentCollection>
                                <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                                    <div id="divList">
                                        <div>

                                        </div>
                                        <div align="center">
                                            <dx:ASPxGridView ID="gvList" ClientInstanceName="gvList" runat="server" EnableCallBacks="false" AutoGenerateColumns="False" KeyFieldName="ID" Theme="Aqua1" Width="100%" OnCustomCallback="gvList_CustomCallback">
                                                <Columns>
                                                    <dx:GridViewDataTextColumn FieldName="S_YONGHUH" Caption="用户号" Width="10%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="S_YONGHUM" Caption="用户名" Width="40%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="LX" Caption="类型" Width="20%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="I_SHUILIANG" Caption="水量" Width="10%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn Width="10%">
                                                        <DataItemTemplate>
                                                            <a href="#" onclick="display('edit','<%#Eval("ID")%>')">修改</a>
                                                        </DataItemTemplate>
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn Width="10%">
                                                        <DataItemTemplate>
                                                            <a href="#" onclick="del('<%#Eval("ID")%>')">删除</a>
                                                        </DataItemTemplate>
                                                    </dx:GridViewDataTextColumn>
                                                </Columns>
                                                <Settings  HorizontalScrollBarMode="Auto" />
                                                <SettingsPager Mode="EndlessPaging" PageSize="100" />
                                                <SettingsBehavior AllowFocusedRow="True"  ColumnResizeMode="Control" />
                                                <ClientSideEvents Init="function(s,e){AdjustSize(500,gvList);}" />
                                            </dx:ASPxGridView>
                                           
                                        </div>
                                    </div>
                                    <div style="height: 3px;"></div>
                                    <div style="text-align: right">
                                        <hr />
                                        <dx:ASPxButton ID="btnAdd" ClientInstanceName="btnAdd" runat="server" Text="添加" AutoPostBack="false" ClientSideEvents-Click="function(s,e){display('add',-1)}" UseSubmitBehavior="false">
                                        </dx:ASPxButton>
                                    </div>
                                    <div id="GridViewContentTable" style="display: none;">
                                        <div class="tabletitle1" align="center">
                                            <dx:ASPxLabel ID="lblOperateTip" runat="server" ClientInstanceName="lblOperateTip" Text="添加"></dx:ASPxLabel>
                                        </div>
                                        <table style="width: 65%; margin: auto;" class="TableLayoutFont">
                                            <tr>
                                                <td align="right" style="width: 20%;">用户号：</td>
                                                
                                                <td style="width: 30%;">
                                                    <dx:ASPxTextBox ID="txtYongHuH" ClientInstanceName="txtYongHuH" runat="server" Width="60%" ClientEnabled="true" MaxLength="7">
                                                        <ClientSideEvents KeyPress="function(s,e){var key = event.keyCode;if( key==13){Search();}}"/>
                                                    </dx:ASPxTextBox>
                                                </td>
                                                </tr>
                                            <tr>
                                                <td align="right" style="width: 20%;">用户名：
                                                </td>
                                                <td style="width: 30%;">
                                                    <dx:ASPxTextBox ID="txtYongHuM" ClientInstanceName="txtYongHuM" runat="server" Width="80%" ClientEnabled="false">
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right">特殊类型：
                                                </td>
                                                <td>
                                                    <asp:Panel runat="server" ID="Panel2">
                                                        <dx:ASPxComboBox runat="server" ID="cmbTeShuLX" Width="60%" ClientInstanceName="cmbTeShuLX">
                                                            <Items>
                                                                <dx:ListEditItem Text="预结算下年" Value="0" />
                                                                <dx:ListEditItem Text="采多抄" Value="2" />
                                                                <dx:ListEditItem Text="灌多抄" Value="3" />
                                                            </Items>
                                                            <ClientSideEvents KeyPress="function(s,e){OnKeyNext(txtShuiLiang);}" />
                                                        </dx:ASPxComboBox>
                                                    </asp:Panel>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right">录入水量：
                                                </td>
                                                <td>
                                                    <dx:ASPxTextBox ID="txtShuiLiang" ClientInstanceName="txtShuiLiang" runat="server" Width="60%" MaxLength="30">
                                                        <ClientSideEvents KeyPress="function(s,e){OnKeyNext(btnSave);}" />
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                        </table>
                                        <table id="GridViewButtonTable" runat="server" width="100%">
                                            <tr>
                                                <td style="text-align: right;">
                                                    <hr />
                                                    <dx:ASPxButton ID="btnSave" ClientInstanceName="btnSave" runat="server" Text="保存" AutoPostBack="false" UseSubmitBehavior="false" ClientSideEvents-Click="function(s,e){save();}">
                                                    </dx:ASPxButton>
                                                    <dx:ASPxButton ID="btnCancel" runat="server" Text="放弃" AutoPostBack="false" ClientSideEvents-Click="function(s,e){display('init',-1);}" UseSubmitBehavior="false">
                                                    </dx:ASPxButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </dx:ContentControl>
                            </ContentCollection>
                        </dx:TabPage>
                        <dx:TabPage Text="采灌井结账">
                            <ContentCollection>
                                <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                                     <table>
                                         <tr style="text-align:center;">
                                             <td>
                                                  <dx:ASPxLoadingPanel ID="LoadPanel22" ClientInstanceName="LoadPanel22" runat="server" Text="正在结账..."></dx:ASPxLoadingPanel> 
                                                 <dx:ASPxButton runat="server" ID="btnCaiGuanJJZ" Text="采灌井结账" OnClick="btnCaiGuanJJZ_Click" UseSubmitBehavior="false">
                                                     <ClientSideEvents Click="function(s,e){LoadPanel22.Show();}" />
                                                 </dx:ASPxButton>
                                                  <dx:ASPxLoadingPanel ID="LoadPanel222" ClientInstanceName="LoadPanel222" runat="server" Text="正在开账..."></dx:ASPxLoadingPanel> 
                                                  <dx:ASPxButton runat="server" ID="btnCaiGuanJKZ" Text="采灌井开账" OnClick="btnCaiGuanJKZ_Click" UseSubmitBehavior="false">
                                                      <ClientSideEvents Click="function(s,e){LoadPanel222.Show();}" />
                                                 </dx:ASPxButton>
                                                 
                                                 <dx:ASPxButton runat="server" ID="btnCaiGuanJJZJS" ClientInstanceName="btnCaiGuanJJZJS" Text="采灌井结账结束" UseSubmitBehavior="false"  AutoPostBack="false">
                                                     <ClientSideEvents  Click="function(s,e){GetNextY();}"/>
                                                 </dx:ASPxButton> 
                                             </td>
                                         </tr>
                                     </table>
                                    <fieldset style="border: 1px solid  cornflowerblue;">
                                        <dx:ASPxMemo ID="txtCGJJG" runat="server" Height="450px" Width="100%"  ReadOnly="true"></dx:ASPxMemo>
                                    </fieldset>
                                </dx:ContentControl>
                            </ContentCollection>
                        </dx:TabPage>
                    </TabPages>
                </dx:ASPxPageControl>

            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
